//
//  HMTEDListPopView.m
//  HowToDo
//
//  Created by 胡坤 on 2017/1/7.
//  Copyright © 2017年 KY. All rights reserved.
//

#import "HMTEDListPopView.h"

@interface HMTEDListPopView ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UIView* topView;
@property(nonatomic,strong)UITableView *listTab;
@property(nonatomic,strong)UIButton *cancleBtn;
@end
@implementation HMTEDListPopView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setUPUI];
    }
    return self;
}

-(void)setUPUI
{
    //设置头部视图
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.left.right.equalTo(self);
        make.height.mas_equalTo(HMCOMMONBAR_HEIGHT);
    }];
    //取消按钮
    [self.cancleBtn setImage:[UIImage imageNamed:@"new_audio_text_dismiss"] forState:UIControlStateNormal];
    [self.cancleBtn addTarget:self action:@selector(dismissCurrentView) forControlEvents:UIControlEventTouchUpInside];
    [self.cancleBtn mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.top.equalTo(self.topView);
    }];
    //下面的展示列表视图
    [self.listTab mas_makeConstraints:^(MASConstraintMaker *make)
    {
         make.top.equalTo(self.topView.mas_bottom);
         make.bottom.left.right.equalTo(self);
    }];
    [self.listTab registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];

}
//按钮的点击事件
-(void)dismissCurrentView
{
    self.dismissActionPerform();
}
#pragma mark --dataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    return cell;
}
-(UIView *)topView
{
    if (!_topView)
    {
        _topView = [[UIView alloc]init];
        _topView.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [self addSubview:_topView];
    }
    return _topView;
}
-(UITableView *)listTab
{
    if (!_listTab) {
        _listTab = [[UITableView alloc]init];
        _listTab.dataSource = self;
        _listTab.delegate = self;
        [self addSubview:_listTab];
    }
    return _listTab;
}
- (UIButton *)cancleBtn
{
    if (!_cancleBtn)
    {
        _cancleBtn = [[UIButton alloc]init];
        
        [self addSubview:_cancleBtn];
    }
    return _cancleBtn;
}
@end
